package tree;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class isValidBST {
    List<Integer> result = new ArrayList<>();
    public boolean isValidBST(TreeNode root) {
        if (root == null){
            return true;
        }
        isValid(root);
        for (int i = 0; i < result.size() - 1; i++) {
            if (result.get(i) >= result.get(i+1)){
                return false;
            }
        }
        return true;
    }
    public void isValid(TreeNode root){
        if (root == null){
            return;
        }
        isValid(root.left);
        result.add(root.val);
        isValid(root.right);
    }
}
